package net.togogo.web.service;

import net.togogo.web.entity.User;
import net.togogo.web.entity.UserExample;
import net.togogo.web.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService {

    @Resource
    UserMapper userMapper;

    //登录
    public User Login(String username,String password){
        UserExample userExample = new UserExample();
        UserExample.Criteria criteria = userExample.createCriteria();
        criteria.andUserEqualTo(username);
        criteria.andPasswordEqualTo(password);
        List<User> users = userMapper.selectByExample(userExample);
        if (users !=null && users.size() > 0){
            User user = users.get(0);
            return user;
        }
        return null;
    }
}
